#include <iostream>
#include <variant>

int main()
{
    std::variant<int,double,std::string> v("hello");
    std::cout<<v.index()<<std::endl;

    
    //通过下标去取值
    std::cout<<std::get<2>(v)<<std::endl;
    //通过类型去取值
    std::cout<<std::get<std::string>(v)<<std::endl;

    return 0;
}